package com.pm.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.pm.common.annotation.Log;
import com.pm.common.core.controller.BaseController;
import com.pm.common.core.domain.AjaxResult;
import com.pm.common.enums.BusinessType;
import com.pm.business.domain.CompeteEnterpriseGrade;
import com.pm.business.service.ICompeteEnterpriseGradeService;
import com.pm.common.utils.poi.ExcelUtil;
import com.pm.common.core.page.TableDataInfo;

/**
 * 企业评价Controller
 * 
 * @author zxl
 * @date 2022-07-11
 */
@RestController
@RequestMapping("/business/grade")
public class CompeteEnterpriseGradeController extends BaseController
{
    @Autowired
    private ICompeteEnterpriseGradeService competeEnterpriseGradeService;

    /**
     * 查询企业评价列表
     */
    @PreAuthorize("@ss.hasPermi('business:grade:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompeteEnterpriseGrade competeEnterpriseGrade)
    {
        startPage();
        List<CompeteEnterpriseGrade> list = competeEnterpriseGradeService.selectCompeteEnterpriseGradeList(competeEnterpriseGrade);
        return getDataTable(list);
    }

    /**
     * 导出企业评价列表
     */
    @PreAuthorize("@ss.hasPermi('business:grade:export')")
    @Log(title = "企业评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CompeteEnterpriseGrade competeEnterpriseGrade)
    {
        List<CompeteEnterpriseGrade> list = competeEnterpriseGradeService.selectCompeteEnterpriseGradeList(competeEnterpriseGrade);
        ExcelUtil<CompeteEnterpriseGrade> util = new ExcelUtil<CompeteEnterpriseGrade>(CompeteEnterpriseGrade.class);
        util.exportExcel(response, list, "企业评价数据");
    }

    /**
     * 获取企业评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:grade:query')")
    @GetMapping(value = "/{gradeId}")
    public AjaxResult getInfo(@PathVariable("gradeId") Long gradeId)
    {
        return AjaxResult.success(competeEnterpriseGradeService.selectCompeteEnterpriseGradeByGradeId(gradeId));
    }

    /**
     * 新增企业评价
     */
    @PreAuthorize("@ss.hasPermi('business:grade:add')")
    @Log(title = "企业评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompeteEnterpriseGrade competeEnterpriseGrade)
    {
        return toAjax(competeEnterpriseGradeService.insertCompeteEnterpriseGrade(competeEnterpriseGrade));
    }

    /**
     * 修改企业评价
     */
    @PreAuthorize("@ss.hasPermi('business:grade:edit')")
    @Log(title = "企业评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompeteEnterpriseGrade competeEnterpriseGrade)
    {
        return toAjax(competeEnterpriseGradeService.updateCompeteEnterpriseGrade(competeEnterpriseGrade));
    }

    /**
     * 删除企业评价
     */
    @PreAuthorize("@ss.hasPermi('business:grade:remove')")
    @Log(title = "企业评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{gradeIds}")
    public AjaxResult remove(@PathVariable Long[] gradeIds)
    {
        return toAjax(competeEnterpriseGradeService.deleteCompeteEnterpriseGradeByGradeIds(gradeIds));
    }
}
